#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int pos = 0;
	if (s[pos] != 'm' && s[pos] != 'M') {
		cout << "NO" << endl;
		return;
	}
	while (s[pos] == 'm'||s[pos]=='M') pos++;
	if (s[pos] != 'e'&& s[pos] != 'E'){
		cout << "NO" << endl;
		return;
	}
	while (s[pos] == 'e' || s[pos] == 'E') pos++;
	if (s[pos] != 'o' && s[pos] != 'O') {
		cout << "NO" << endl;
		return;
	}
	while (s[pos] == 'o' || s[pos] == 'O') pos++;
	if (s[pos] != 'w' && s[pos] != 'W') {
		cout << "NO" << endl;
		return;
	}
	while (s[pos] == 'w' || s[pos] == 'W') pos++;
	if (pos == n) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}